<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>添加新员工</title>
  </head>
  
  <body>
  
    	<div class="container" style="width:800px">
		  <div class="row">
			<div class="span9">
				<form action="addmember.jspx" method="post" id="form">
			        <fieldset style="margin-left:100px;margin-top:30px">
			        	
		        		 <legend>添加新员工</legend>
				          <div class="control-group">
				            <label for="input01" class="control-label">新员工用户名</label>
				            <div class="controls">
				              <input type="text" style="height:32px" name="username" id="input01" class="span5">
				              <span style="color:red" id="input01_msg"></span>
				            </div>
				          </div>
				          
				          <div class="form-actions">
				            <button style="margin-left:100px" class="btn btn-primary" id="btn" type="button">保存</button>
				            <a class="btn" href="projectlist.jspx">返回</a>
				          </div>
			         
			        </fieldset>
	      		</form>          
	          	
			</div>
		  </div>
		</div>
	<script type="text/javascript">
		$(document).ready(function(){
			var name=$("#input01");
			var msg=$("#input01_msg");
			var btn=$("#btn");
			var flag=false;
			
			name.blur(function(){
				if(name.val()==""){
					msg.text("请输入用户名");
				}else{
					msg.text("");
					
					$.get("memberajax.jspx",{name:name.val()},function(result){
						if(result=="ok"){
							flag=true;
							msg.text("恭喜您，该用户名可以使用");
						}else{
							msg.text("用户名已被占用");
							flag=false;
						}
					});
				}
				
			});
			
			btn.click(function(){
				if(flag){
					$("#form").submit();
				}
			});
			
		});
	</script>
  </body>
</html>
